package com.itjh.pojo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class MyResponseResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public static <T> MyResponseResult<T> success(T data) {
        return MyResponseResult.<T>builder().code(1).data(data).msg("success").build();
    }

    public static <T> MyResponseResult<T> success(Integer code, String msg, T data) {
        return MyResponseResult.<T>builder().code(code).data(data).msg(msg).build();
    }

    public static <T> MyResponseResult<T> error(String msg) {
        return MyResponseResult.<T>builder().code(0).data(null).msg(msg).build();
    }

    public static <T> MyResponseResult<T> error(Integer code, String msg, T data) {
        return MyResponseResult.<T>builder().code(code).data(data).msg(msg).build();
    }
}